import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

// 组合式写法
// defineStore(StoreName,setup)
// StoreName  模块名称 => pinia天生就支持模块化
// setup      setup函数 => 模块的配置 组合式写法
export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  const doubleCount = computed(() => count.value * 2)
  function addCount() {
    count.value++
  }

  return { count, doubleCount, addCount }
})
